# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rr
_gemname=rr
pkgver=3.1.0
pkgrel=2
pkgdesc="Test double framework that features a rich selection of double techniques"
url="https://github.com/rr/rr"
arch="noarch"
license="MIT"
depends="ruby"
checkdepends="
	ruby-minitest
	ruby-test-unit
	ruby-test-unit-rr
	"
makedepends="ruby-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/rr/rr/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"
options="!check"  # avoid circular dependency with ruby-test-unit-rr

build() {
	gem build $_gemname.gemspec
}

check() {
	RR_INTEGRATION=minitest ruby test/run-test.rb
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnessecary files
	cd "$gemdir"
	rm -rf build_info cache extensions plugins
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
d05d8421d5cd6e9225cbf5ca183c54cc510a3212f0629f7cee60887b18c874618cb67836503aed7665cef8443cc579306b84e030ae1ec0834f56298f5044a2fa  rr-3.1.0.tar.gz
6712e6b870d6145718ef656e0e299f1cf8749b9f695d9227f3ad7fd3ad19ec001f49be523ef245dccd84bca6ce24b4e397d8468b7a0c1c6af5edb7ef2508f11d  gemspec.patch
"
